/*@ File Name : doublelinkedlist.h
  @ Date : 18/11/2011
  @ Author : Guillaume Collombet, Ulysse Mensa, Sylvain Chambe

Fireworks simulation projet
Copyright (C) 2011 Guillaume Collombet, Ulysse Mensa, Sylvain Chambe

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

You can contact us by sending mail at fireworks-simulation-project@googlecode.com*/

#if !defined(_DOUBLELINKEDLIST_H)
#define _DOUBLELINKEDLIST_H

#include "const.h"

#include <malloc.h>

typedef void* Element;

struct s_DoubleCell
{
  Element value;
  struct s_DoubleCell* next;
  struct s_DoubleCell* previous;
} typedef DoubleCell;

struct s_List
{
  DoubleCell *first;
  DoubleCell *last;
  int count;
} typedef List;

void DoubleLinkedList_Init(List * l);
void DoubleLinkedList_Copy(const List * source,List** destination);
int DoubleLinkedList_IsEmpty(const List * l);
DoubleCell* DoubleLinkedList_InsertAt(List* l, Element e, int position);
DoubleCell* DoubleLinkedList_Insert(List* l, Element e, Element at);
void DoubleLinkedList_InsertFirst(List* l,Element e);
void DoubleLinkedList_InsertLast(List* l,Element  e);
Element DoubleLinkedList_GetFirst(const List* l);
Element DoubleLinkedList_GetLast(const List* l);
Element DoubleLinkedList_ReadFirst(List* l);
Element DoubleLinkedList_ReadLast(List* l);
DoubleCell* DoubleLinkedList_Search(const List* l,Element e);
DoubleCell* DoubleLinkedList_SearchFromLast(const List* l,Element e);
void List_Destroy(List* l);

#endif /*_DOUBLELINKEDLIST_H*/
